package com.carman.pos.upgrade;

import com.carman.pos.api.UsbApi;
import com.hisense.pos.hs_msr.R;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class LoginActivity extends Activity{

	private UsbApi usbApi = new UsbApi(this);
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		
		setContentView(R.layout.activity_login);
		
		boolean bret = usbApi.init();
        if(!bret) {
        	return;
        }
		
		Button btn_enter = (Button)findViewById(R.id.btn_login_enter);
		btn_enter.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				int iret = usbApi.write(new byte[] {0x1D,0x75,0x55,(byte) 0xaa}, 0, 4, 1000);
            	Log.i("carman", "iret = " + iret);
            	if(iret == UsbApi.SUCCESS) {
            		usbApi.destory();
	            	Intent intent = new Intent();
	            	intent.setClass(LoginActivity.this, UpgradeActivity.class);
	            	startActivity(intent);
            	}
			}
		});
	}
}
